define(['app'], function(app) {
	'use strict';

	// 实例化方法
	var factory = function(Http) {
		function get_data_refund_list(result) {
			if(false) {
				result = '{"sucsse":true,"msg":"value","result":{"page":[{"limit":8,"tPage":1,"cPage":5,"count":"value"}],"order":[{"order_id":1,"status":"2","member_id":123,"uname":"王大锤","apply_time":"2020-12-12","comp_id":123,"shop_no":12345678,"is_intervene":3,"refund_status":1},{"order_id":2,"status":"12","member_id":123,"uname":"王大锤","apply_time":"2020-13-12","comp_id":1234,"shop_no":123456784,"is_intervene":2,"refund_status":3},{"order_id":1,"status":"16","member_id":123,"uname":"王大锤","apply_time":"2020-12-12","comp_id":123,"shop_no":12345678,"is_intervene":3,"refund_status":4},{"order_id":1,"status":"5","member_id":123,"uname":"王大锤","apply_time":"2020-12-12","comp_id":123,"shop_no":12345678,"is_intervene":3,"refund_status":2}]}}';
				return JSON.parse(result);
			} else
				return result;
		}
		function get_data_return_agree(result){
			if(false){
				result = '{"sucsse":true,"msg":"value","result":{"order_id":1}}';
				return JSON.parse(result);
			}else
			return result;
		}
		function get_data_return_refuse(result){
			if(false){
				result = '{"sucsse":true,"msg":"value","result":{"order_id":1}}';
				return JSON.parse(result);
			}else
			return result;
		}
		function get_data_return_finish(result){
			if(false){
				result = '{"sucsse":true,"msg":"value","result":{"order_id":1}}';
				return JSON.parse(result);
			}else
			return result;
		}
		// 返回信息
		return {
			// 获取首页数据
			get_sellerrefund: function(callback) {

				var data = new Object();

				data.saleman = [{
					name: '制造商1',
					fouce: '4744',
					trade: '77143',
					sale: '4328262',
					count: '94222'
				}, {
					name: '制造商2',
					fouce: '4724',
					trade: '77453',
					sale: '482362',
					count: '98322'
				}, {
					name: '制造商3',
					fouce: '4734',
					trade: '77343',
					sale: '482262',
					count: '94542'
				}, {
					name: '制造商4',
					fouce: '4734',
					trade: '77343',
					sale: '482262',
					count: '94542'
				}, {
					name: '制造商5',
					fouce: '4734',
					trade: '77343',
					sale: '482262',
					count: '94542'
				}];

				data.city = [{
					name: '上海',
					fouce: '4744',
					trade: '77143',
					sale: '4328262',
					count: '94222'
				}, {
					name: '北京',
					fouce: '4724',
					trade: '77453',
					sale: '482362',
					count: '98322'
				}];

				// 函数回调
				if(callback)
					callback(data);

			},
			refund_list: function(type, callback) {
				Http.post({
					method: 'order.return.getlist',
					pagelimit: 8,
					nPage: 1,
					order_kind:2,
					type: type
				}, function(result) {
				    console.log(result)
					if(callback)
						callback(get_data_refund_list(result).result);
				}, function(e) {

				}, function() {

				})
			},
			return_agree:function(order_id,type,callback){
				Http.post({
					method:'order.return.agree',
					order_id:order_id,
					type:type
				},function(result){
					if(callback)
					callback(get_data_return_agree(result));
				},function(e){

				},function(){

				})
			},
			return_refuse:function(order_id,reason,type,callback){
				Http.post({
					method:'order.return.refuse',
					order_id:order_id,
					reason:reason,
					type:type
				},function(result){
					if(callback)
					callback(get_data_return_refuse(result));
				},function(e){

				},function(){

				})
			},
			return_finish:function(order_id,callback){
				Http.post({
					mehtod:'order.return.finish',
					order_id:order_id
				},function(result){
//					if(callback)
//					callback(get_data_return_finish(result));
				},function(e){

				},function(){

				})
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Sellerrefund", factory);
});